package com.spring.hot;

/**
 * @author Cizai
 * @since 2022/12/01 18:27
 * @see <a href="https://leetcode.cn/problems/container-with-most-water/?favorite=2cktkvj">...</a>
 **/
public class 盛最多水的容器 {

    public int maxArea(int[] height) {

        int left = 0;
        int right = height.length - 1;

        int max = 0;
        while (left < right) {
            if (height[left] > height[right]) max = Math.max(max,(right-left)*height[right--]);
            else max = Math.max(max,(right - left)*height[left++]);
        }
        return max;
    }
}
